# Maintainer: Lukas Fleischer <lfleischer@archlinux.org>
# Maintainer: George Rawlinson <grawlinson@archlinux.org>
# Contributor: Eric Belanger <eric@archlinux.org>
# Contributor: Judd Vinet <jvinet@zeroflux.org>

pkgname=tcsh
pkgver=6.24.10
pkgrel=1
pkgdesc='Enhanced version of the Berkeley C shell'
arch=('loong64' 'x86_64')
url='https://www.tcsh.org/'
license=('BSD')
depends=('glibc' 'ncurses' 'libxcrypt')
backup=('etc/csh.cshrc'
        'etc/csh.login')
install='tcsh.install'
source=(https://astron.com/pub/tcsh/tcsh-${pkgver}.tar.gz{,.asc}
        'csh.cshrc'
        'csh.login')
validpgpkeys=('AD87109763D8D8C2C94CBA8065C26E471F45B123') # Kimmo Suominen
sha512sums=('74bd17f4d8bb1fb60a2a6904d87e26b7490f0ec571866e62d6e1d35e9da435c888ab14bfa842d7282e8993d366580439b4cc884b08a22e45dc98a36f813094be'
            'SKIP'
            '0710c014b7b42ba8c69beb20ec2b8da44c9318013e83e8a38b2c94da1b11beb50a62cc9d82b7db1b3ee79bb0acf5f2a199e2ee2d745d541ea787e3c6a0069844'
            '97f9f3e376517bd47aee67b48456b4892e0cb2c6f9c3e4b49d7b75cc23f52e69b06f024fbca1e72442d443720753b93fd9714160e551eab54d3de3757268d2d7')
b2sums=('bf6e5815390ecffa9dbdc31ac08630ebc3e95394092285cc2f5c5cf0bb48c16ccdd195888feb9e3f5cc689c228eed7a99a2edb566be696bf95851c8176ce3c7b'
        'SKIP'
        '016e65a672aba6d9b7283d63435a8ebd01818d56f11fb3c1203b1fd51fb1a67760c8f53b22be409319b3db18b0f81df09103de673579a5a5e1b6e07109069f94'
        'da0fa27875507d646e869c5a8cdfecb793cd848c38e626704cdf5adb8ec2eef7fd98e3bab6eceea7d99fda25093364c48a8c44417575574a5ad0753b87cef2e3')

build() {
  cd "$pkgname-$pkgver"

  ./configure \
    --prefix=/usr \
    --sysconfdir=/etc \
    --bindir=/usr/bin

  make
}

package() {
  cd "$pkgname-$pkgver"

  make DESTDIR="$pkgdir" mandir=/usr/share/man install install.man

  # shell configuration
  install -vDm644 -t "$pkgdir/etc" ../csh.{cshrc,login}

  # symlinks for tcsh -> csh
  ln -s tcsh "$pkgdir/usr/bin/csh"
  ln -s tcsh.1 "$pkgdir/usr/share/man/man1/csh.1"

  # license
  install -vDm644 -t "$pkgdir/usr/share/licenses/$pkgname" Copyright
}
